import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:qunaimedical/models/check_item.dart';
import 'package:qunaimedical/pages/patient_manage/check_item_detail.dart';

/// 检查报告
class ItemHealthCheck extends StatelessWidget {
  final CheckItem item;
  final VoidCallback onDelete;

  const ItemHealthCheck({Key key, this.item, this.onDelete}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Slidable(
      actionPane: SlidableDrawerActionPane(),
      actionExtentRatio: 0.2,
      secondaryActions: <Widget>[
        IconSlideAction(
          caption: '删除',
          color: Colors.red,
          icon: Icons.delete_forever,
          onTap: onDelete,
        ),
      ],
      child: InkWell(
        onTap: () {
          Navigator.push(context,
              MaterialPageRoute(builder: (c) => CheckItemDetail(item)));
        },
        child: Container(
          height: 100,
          color: Colors.white,
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.all(10),
                child: Image.asset(
                  'assets/images/ic_check_item.png',
                  width: 50,
                ),
              ),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Text(
                      item.checkName,
                      maxLines: 1,
                      style:
                          TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
                      overflow: TextOverflow.ellipsis,
                    ),
                    Text(
                      '检测时间：${item.checkTime}',
                      style: TextStyle(color: Colors.grey),
                    ),
                    Text(
                      '检测内容：共${item.enclosure == '' ? 0 : item.enclosure.split(',').length}张图片',
                      style: TextStyle(color: Colors.grey),
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
